<template>
  <div class="rateQuery">
    <div v-if="feeTypeName" style="margin-left:15vw">
      <h3 style="font-size: 14px;">
        模板类型：{{ feeTypeName }}
        <span style="margin-left:30%">模板名称：{{ feename }}</span>
      </h3>
    </div>
    <div style="width: 90%;margin:20px auto;">
        <mer-rate-view :MerRateList="MerRateList" ref="getMerRateData"></mer-rate-view>
    </div>
    <div style="width: 90%;margin-left:15vw">
      是否为默认模板：
      <span v-if="defaultValue">是</span>
      <span v-if="!defaultValue">否</span>
    </div>
    <div style="text-align:center;margin: 20px 0;">
      <a-button type="primary" style="width: 8vw;" @click="goModify">
        <span>修改</span>
        <!-- <span v-if="isChange == false">审核中</span> -->
      </a-button>
      <a-button
        type="primary"
        style="width: 8vw;margin-left:10px"
        @click="delrate"
      >
        <span>删除</span>
      </a-button>
    </div>


    <a-modal title="删除模板" v-model="delvisible" :footer="null">
      <div>确认删除{{ feename }}模板？</div>
      <div style="text-align:center;margin: 20px 0;">
        <a-button type="primary" style="width: 8vw;" @click="delok">
          <span>确认</span>
          <!-- <span v-if="isChange == false">审核中</span> -->
        </a-button>
        <a-button
          type="primary"
          style="width: 8vw;margin-left:10px"
          @click="delpass"
        >
          <span>取消</span>
        </a-button>
      </div>
    </a-modal>
  </div>
</template>
<script>
import MerRateView from "../../common/MerRateView";
export default {
  components: {
    MerRateView
  },
  data() {
    return {
      MerRateList:null,
      query: {},
      queryid: "",
      feeTypeName: "",
      feename: "",
      visible: false,
      defaultValue: false,
      delvisible: false,
      iconLoading: false,
      issend: true,
      isChange: true,
    };
  },
  mounted() {},
  activated() {
    this.queryid = this.$route.params.id;
    // this.feeTypeName = this.$route.params.feeTypeName;
    // this.feename = this.$route.params.name;
    this.getratelist();
  },

  methods: {
    getratelist() {
      this.$axios.get("/agent/fee/group/getById/" + this.queryid).then(res => {
      
        if (res.data.code == "OK") {
          // this.isChange = res.data.data.isChange
          this.MerRateList = res.data.data.feeTemplateDTOMap;
          this.defaultValue = res.data.data.defaultValue;
          this.feeTypeName = res.data.data.feeTypeName
          this.feename = res.data.data.name
        
        } else {
          // this.spinning=false;
        }
      });
    },
    goModify() {
      this.$router.push(`/org/transmanage/merratequerychange/${this.queryid}`)
      
    },
    delrate() {
      if(this.defaultValue == true){
        this.$message.info("无法删除默认模板")
      }else{
        this.delvisible = true;
      }
      
    },
    delok() {
      this.$axios
        .get("/agent/fee/group/deleteById/" + this.queryid)
        .then(res => {
          if (res.data.code == "OK") {
            this.delvisible = false;
            this.$router.push("/org/transmanage/rateTemplate");
          } else {
            this.$message.warning(res.data.message);
          }
        });
    },
    delpass() {
      this.delvisible = false;
    },
    orgSubmit(e) {
      e.preventDefault();
      this.form.validateFields((err, values) => {
        if (!err) {
          this.$axios
            .post("/agent/merchant/account/send/mobile/check", this.query)
            .then(res => {
              console.log("sendmobile", res);
              if (res.data.code == "OK") {
                this.visible = false;
                this.$router.push("/org/transmanage/ratequerychange");
              } else {
                this.$message.warning(res.data.message);
              }
            });
        }
      });
    },
    getCode() {
      this.iconLoading = true;

      this.$axios
        .post("/agent/merchant/account/send/mobile/check", {
          mobileNo: this.query.mobileNo
        })
        .then(
          res => {
            this.iconLoading = false;
            // console.log("code",res)
            if (res.data.code == "OK") {
              const TIME_COUNT = 60;
              if (!this.timer) {
                this.count = TIME_COUNT;
                this.issend = false;
                this.timer = setInterval(() => {
                  if (this.count > 0 && this.count <= TIME_COUNT) {
                    this.count--;
                  } else {
                    this.issend = true;
                    clearInterval(this.timer);
                    this.timer = null;
                  }
                }, 1000);
              }
            } else {
              this.$message.warning(res.data.message);
              this.issend = true;
            }
            // this.$message.warning(res.message);
          },
          err => {
            this.iconLoading = false;
            console.log(err);
          }
        );
    }
  }
};
</script>
<style lang="less" scoped>
/deep/.noExpand {
  .ant-table-row-expand-icon {
    display: none;
  }
}
.rateQuery {
  overflow: scroll;
  height: 100%;
  padding: 30px;
  overflow-x: hidden;
  overflow-y: auto;
}
/*滚动条样式*/
.rateQuery::-webkit-scrollbar {
  /*滚动条整体样式*/
  width: 4px;
  /*高宽分别对应横竖滚动条的尺寸*/
  height: 4px;
}

.rateQuery::-webkit-scrollbar-thumb {
  /*滚动条里面小方块*/
  border-radius: 5px;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.2);
}

.rateQuery::-webkit-scrollbar-track {
  /*滚动条里面轨道*/
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.1);
}
</style>
